<script type="text/javascript" src="/js/epicrisis_ingresos.js"></script>
    
<div id="titulo_encabezado">
    <div style="padding: 5px;">
	<?php echo __('Registrar Nuevo Ingreso', true) ?>
    </div>
</div>

<div id="contenido_gral">

    <form action='/ingresos/pacientenuevo' method='post' id='frm_ingresos'>
        <h1>Es un paciente nuevo, por favor ingrese los datos del mismo:</h1>
        <table class='table' style='width:100%;'>
            <tr style='height:60px;'>
                <td width="33%">
                    <div class="input text required">
                        <label for="name" class='label_grande'>1er. Nombre</label>
                        <input name="data[name]" type="text" value="<?php echo $data['name'];?>" id="name" class='input_grande' required>
                            <?php if(isset($errores['name'])){ echo $errores['name'];} ;?>
                    </div>
                </td>
                <td width="33%">
                    <div class="input text">
                        <label for="name2" class='label_grande'>2do. Nombre</label>
                        <input name="data[name2]" type="text" value="<?php echo $data['name2'];?>" id="name2" class='input_grande'>
                    </div>
                </td>
                <td width="33%">
                    <div class="input text">
                        <label for="name3" class='label_grande'>Otros Nombres</label>
                        <input name="data[name3]" type="text" value="<?php echo $data['name3'];?>" id="name3" class='input_grande'>
                    </div>
                </td>
            </tr>	


            <tr style='height:60px;'>
                <td>
                    <div class="input text required">
                        <label for="lastname" class='label_grande'>Apellido</label>
                        <input name="data[lastname]" type="text" value="<?php echo $data['lastname'];?>" id="lastname" class='input_grande' required>
                            <?php if(isset($errores['lastname'])){ echo $errores['lastname'];} ;?>
                    </div>
                </td>
                <td>
                    <div class="input text">
                        <label for="lastname2" class='label_grande'>Apellido Materno</label>
                        <input name="data[lastname2]" type="text" value="<?php echo $data['lastname2'];?>" id="lastname2" class='input_grande'>
                    </div>
                </td>
                <td>
                </td>
            </tr>	

            <tr style='height:60px;'>
                <td>
                    <div class="input text">
                        <label for="gender" class='label_grande'>Género</label>
                            <?php echo $this->Form->input('gender_id',array(
			  					'type'=>'select',
			  					'options'=>$genders, 
			  					'label' => false,
			  					'empty' => '--- Seleccione uno ---',
                                'value' => $data['gender_id']
			  					));
                            ?>
                            <?php if(isset($errores['gender_id'])){ echo $errores['gender_id'];} ;?>
                    </div>
                </td>
                <td>
                    <div class="input text">
                        <label for="sex_id" class='label_grande'>Sexo</label>
                            <?php echo $this->Form->input('sex_id',array( 
			  					'label' => false, 
		  						'type'=>'select',
		  						'options'=>$sexes, 
								'empty' => '--- Seleccione uno ---',
                                'value' => $data['sex_id']
                                )); 
                            ?>
                            <?php if(isset($errores['sex_id'])){ echo $errores['sex_id'];} ;?>
                    </div>
                </td>
                <td>
                    <div class="input text">
                        <label for="fecha_nacimiento" class='label_grande'>Fecha de Nacimiento</label>
                        <select name='data[dia_nac]' style='width:60px;margin-right:4px;padding:4px;' required>
            				<?php for($i=1;$i<=31;$i++){?>
                                <?php $sel = ($i==$data['fecha_nac']['dia'] ? 'selected' : '' );?>
                                <option value='<?php echo $i;?>' <?php echo $sel;?> ><?php echo $i;?></option>
				            <?php } //endfor?>
                        </select>
                        /
                        <select name='data[mes_nac]' style='width:60px;margin-right:4px;padding:4px;' required>
                            <?php for($i=1;$i<=12;$i++){?>
                                <?php $sel = ($i==$data['fecha_nac']['mes'] ? 'selected' : '' );?>
                                <option value='<?php echo $i;?>' <?php echo $sel;?> ><?php echo $i;?></option>
				            <?php } //endfor?>
                        </select>
                        /
                        <select name='data[ano_nac]' style='width:90px;margin-right:4px;padding:4px;' required>
                            <?php $hoy = date("Y"); $desde = $hoy-100;?>
				                <?php for($i=$desde; $i<=$hoy; $i++){?>
                                <?php $sel = ($i==$data['fecha_nac']['ano'] ? 'selected' : '' );?>
                                <option value='<?php echo $i;?>' <?php echo $sel;?> ><?php echo $i;?></option>
				            <?php } //endfor?>
                        </select>
                    </div>
                </td>
            </tr>

            <tr style='height:60px;'>
                <td>
                    <div class="input text">
                        <label for="gruposanguineo_id" class='label_grande'>Grupo Sanguíneo</label>
                            <?php echo $this->Form->input('gruposanguineo_id',array( 
			  					'label' => false, 
		  						'type'=>'select',
		  						'options'=>$gruposanguineos, 
								'empty' => '--- Seleccione uno ---')); 
                            ?>
                            <?php if(isset($errores['gruposanguineo_id'])){ echo $errores['gruposanguineo_id'];} ;?>
                    </div>
                </td>

                <td>
                    <div class="input text">
                        <label for="telefono" class='label_grande'>Telefono</label>
                        <input name="data[telefono]" type="text" value="<?php echo $data['telefono'];?>" id="telefono" class='input_grande'>
                    </div>
                </td>
                <td>
                    <div class="input text">
                        <label for="email" class='label_grande'>Email</label>
                        <input name="data[email]" type="text" value="<?php echo $data['email'];?>" id="email" class='input_grande'>
                    </div>
                </td>
            </tr>	

            <tr style='height:60px;'>
                <td>
                    <div class="input text required">
                        <label for="direccion" class='label_grande'>Domicilio</label>
                        <input name="data[direccion]" type="text" value="<?php echo $data['direccion'];?>" id="domicilio" class='input_grande'>
                            <?php if(isset($errores['direccion'])){ echo $errores['direccion'];} ;?>
                    </div>
                </td>
                <td>
                    <div class="input text">
                        <label for="localidad" class='label_grande'>Localidad</label>
                        <input name="data[localidad]" type="text" value="<?php echo $data['localidad'];?>" id="localidad" class='input_grande'>
                            <?php if(isset($errores['localidad'])){ echo $errores['localidad'];} ;?>
                    </div>
                </td>
                <td>
                    <div class="input text">
                        <label for="provincia" class='label_grande'>Provincia</label>
                        <input name="data[provincia]" type="text" value="<?php echo $data['provincia'];?>" id="provincia" class='input_grande'>
                            <?php if(isset($errores['provincia'])){ echo $errores['provincia'];} ;?>
                    </div>
                </td>
            </tr>	

            <tr>
                <td>
   
                    <div class="input text">
                        <label for="Credencial" class='label_grande'>Nro.de Credencial</label>
                        <input name="data[credencial]" type="text" value="<?php echo $data['credencial'];?>" id="credencial" class='input_grande' required readonly>
                            <?php if(isset($errores['credencial'])){ echo $errores['credencial'];} ;?>
                    </div>

                </td>
                <td>

                    <div class="input text">
                        <label for="Documento" class='label_grande'>Tipo y Nro.de Documento</label>
                        <?php foreach($Typodocuments as $typodocument){
                            $tipo_doc = '';
                            if ($data['typodocument_id']==$typodocument['Typodocument']['id']){
                                $tipo_doc = $typodocument['Typodocument']['name'];
                                break;
                            }
                        } //endofreac ?>    
                        <input type='text' value='<?php echo $tipo_doc.': '.$data['nro_documento'];?>' id='documento' class='input_grande' 
                               placeholder='Sólo números' style='width:200px;' required readonly>
                        <?php if(isset($errores['nro_documento'])){ echo $errores['nro_documento'];} ;?>
                        
                        <input name='data[nro_documento]' type='hidden' value='<?php echo $data['nro_documento'];?>'>
                        <input name='data[typodocument_id]' type='hidden' value='<?php echo $data['typodocument_id'];?>'>
                            
                    </div>

                </td>   
                <td></td>
            </tr>	

            <tr>
                <td colspan='3' style='padding-top:20px;text-align:right;'>
                    <div class="input text">
                        <button type="submit" class='btn btn-primary' id='btn_enviar' style='width:220px;padding:10px;'>Guardar datos y asignar turno
                            <img src='/images/btn_loading.gif' id='enviando' style='display:none;margin-left:10px;'>
                        </button>
                    </div>
                </td>
            </tr>
            
        </table>

    </form>
</div>